import { createSSRApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";

// 导入腾讯地图SDK（使用动态import方式，适配TypeScript环境）
import * as QQMapWXModule from './static/js/qqmap-wx-jssdk.min.js';
const QQMapWX = (QQMapWXModule as any).default || QQMapWXModule;

// 暴露QQMapWX到全局，以便在组件中使用
if (globalThis) {
  (globalThis as any).QQMapWX = QQMapWX;
}
if (typeof window !== 'undefined') {
  (window as any).QQMapWX = QQMapWX;
}

export function createApp() {
  const app = createSSRApp(App);
  // 将QQMapWX挂载到app实例，方便在组件中通过inject使用
  app.provide('QQMapWX', QQMapWX);

  const pinia = createPinia();
  app.use(pinia);

  return {
    app,
    pinia,
  };
}
